// 1 引入
import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入组件区域 
// 切换首页作业组件
import Index from '@/views/Index.vue'
import Class from '@/views/Class.vue'
import Order from '@/views/Orders.vue'
import My from '@/views/My.vue'
import NotFound from '@/views/NotFound.vue'
// 二级路由作业组件
import Home from '@/views/Home.vue'
import News from '@/views/News.vue'
import Sports from '@/views/Sports.vue'
// 二级
import SportHome from '@/views/SportHome.vue'
import SportChina from '@/views/SportChina.vue'
import SportOpen from '@/views/SportOpen.vue'

Vue.use(VueRouter)//2 调用
// 3 创建路由实例
const router = new VueRouter({
  routes: [
    // {
    //   path: "/", // 默认hash值路径
    //   redirect: "/index" // 重定向到/index
    // },
    {
      path: '/index',
      component:Index
    },
    {
      path: '/class',
      component:Class
    },
    {
      path: '/order',
      component:Order
    },
    {
      path: '/my',
      component:My
    },
    {
      path: '*',
      component:NotFound
    },
    // 二级路由区域
    {
      path: '/home',
      component:Home
    },
    {
      path: '/news',
      component:News
    },
    {
      path: '/sports',
      component: Sports,
      children: [
        {
          path: '/sporthome',
          component:SportHome
        },
        {
          path: '/sportchina',
          component:SportChina
        },
        {
          path: '/sportopen',
          component:SportOpen
        },
      ]
    },
    {
      path: "/", // 默认hash值路径
      redirect: "/home" // 重定向到/home
    },
  ]
})
// 对外暴露 路由实例
export default router